"""
### 1_cookie[掌握]

*  解释: 用来保持服务器和浏览器交互的状态的, 由服务器设置,存储在浏览器

 * 作用: 用来做广告推送
* cookie的设置和获取
  * 设置cookie: response.set_cookie(key,value,max_age)
    * max_age: 表示cookie在浏览器的存储时间,单位是秒
  * 获取cookie: request.cookies.get("key")
"""""
from flask import Flask, make_response, request

app =Flask(__name__)

@app.route("/set_cookie")
def set_cookie():
    # 调make_response方法获取响应对象
    response = make_response("set_cookie") # 响应行、头、体
    # 设置cookie
    response.set_cookie("computer","leishen")
    response.set_cookie("age", "13",10)
    return response # 响应体

@app.route("/get_cookie")
def get_cookie():
    name = request.cookies.get("computer")
    age = request.cookies.get("age")
    return "name is %s , age is %s"%(name,age)

if __name__ == '__main__':
    app.run(debug=True)